package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.HotelOrder;
import cn.wolfcode.luowowo.article.mapper.HotelOrderMapper;
import cn.wolfcode.luowowo.article.service.IHotelOrderService;
import cn.wolfcode.luowowo.article.vo.HotelVO;
import cn.wolfcode.luowowo.cache.service.IRedisService;
import cn.wolfcode.luowowo.cache.util.RedisKeysUtil;
import cn.wolfcode.luowowo.common.exception.LogicException;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class HotelOrderSerivceImpl implements IHotelOrderService {

    @Autowired
    private HotelOrderMapper hotelOrderMapper;

    @Reference
    private IRedisService redisService;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public void save(HotelOrder record) {
        String key = RedisKeysUtil.VERIFY_CODE.join(record.getPhone());
        String code = redisService.getVerifyCode(key);
        if(code == null){
            throw new LogicException("该验证码已失效");
        }
        hotelOrderMapper.insert(record);
    }

    @Override
    public HotelOrder selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public List<HotelOrder> selectAll() {
        return null;
    }

    @Override
    public int updateByPrimaryKey(HotelOrder record) {
        return 0;
    }
}
